package testcase.command;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;

import junit.framework.TestCase;

import org.junit.Test;

import satir.SatirGame;
import satir.card.MagicToolCard;
import satir.cell.Board;
import satir.cell.Cell;
import satir.cell.EventCell;
import satir.command.RollDiceCmd;
import satir.player.Player;


public class RollDiceCmd_execute_1 extends TestCase{

	
	
	/*
	 * test:1
	 * Test Objective: test the cell execution for player reach a cell, without any display operation
	 */
	@Test
	public void testRollDice_1(){

		class BoardStub extends Board{
			public BoardStub() {
				
			}
			@Override
			public void showBoard() {
			}
			
		}
		
		class EventCellStub extends EventCell{
			public EventCellStub(){
				super(5, 5, '-', '|', null);
			}
			@Override
			public void cellAction(Player target) {
				System.out.println("Empty Cell!Nothing to do!!");
			}
		}
		class PlayerStub extends Player{
			private String name;
			private int selfEsteem;
			private String mtCards;
			public PlayerStub(){
				name = "cliff";
				selfEsteem=5;
				mtCards = "magic" ;
			}
			@Override
			public void addMovement(int addMovement){
			}
			@Override
			public String getName() {
				return name;
			}
			@Override
			public Cell getCurrentCell(){
				return new CellStub();
				
			}
		}
		class SatirGameStub extends SatirGame{
			@Override
			public Player getCurrentPlayer(){
				return new PlayerStub();
			}
			
			@Override
			public Board getBoard() {
				return new BoardStub();
			}
		}
		
		RollDiceCmd cmd = new RollDiceCmd(new SatirGameStub());
		final ByteArrayOutputStream systemOut = new ByteArrayOutputStream();
		System.setOut(new PrintStream(systemOut));

		cmd.execute();

		String actualResult = systemOut.toString();
		int startIndex = actualResult.indexOf('\n') + 1;
		actualResult = actualResult.substring(startIndex,
				actualResult.indexOf('\n', startIndex) - 1);
		startIndex = actualResult.indexOf(' ') + 1;
		actualResult = actualResult.substring(startIndex,
				actualResult.indexOf(startIndex-1));
		int diceNo1 = Integer.parseInt(actualResult);
		
		
		
		assertEquals(actualResult, "Wrong input");
		int diceNo1 = RollDiceCmd.rollDiceMovement;
		
	}
	
	
	
	
	
	
}
